import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/home/index.vue'

const routes = [
    {
        path: '/',
        name: 'Home',
        component: HomeView,
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import('@/views/register/index.vue')
    },
    {
        path: '/register/verification',
        name: 'RegisterVerification',
        component: () => import('@/views/register/verification.vue')
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login/index.vue')
    },
    {
        path: '/login/verification',
        name: 'LoginVerification',
        component: () => import('@/views/login/verification.vue')
    },
    {
        path: '/trade',
        name: 'Trade',
        component: () => import('@/views/trade/index.vue')
    },
    {
        path: '/markets',
        name: 'Markets',
        component: () => import('@/views/markets/index.vue')
    }, {
        path: '/futures',
        name: 'Futures',
        component: () => import('@/views/futures/index.vue')
    }, {
        path: '/multipleChart',
        name: 'MultipleChart',
        component: () => import('@/views/multipleChart/index.vue')
    }, {
        path: '/terms',
        name: 'Terms',
        component: () => import('@/views/terms/index.vue')
    },
    {
        path: '/about',
        name: 'About',
        component: () => import('@/views/about/index.vue')
    },
    {
        path: '/support',
        name: 'Support',
        component: () => import('@/views/support/index.vue')
    },
    {
        path: '/my',
        name: 'My',
        component: () => import('@/views/my/index.vue')
    },
    {
        path: '/security',
        name: 'Security',
        component: () => import('@/views/security/index.vue')
    },
    {
        path: '/contract',
        name: 'Contract',
        component: () => import('@/views/contract/index.vue')
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes,
    scrollBehavior(to, from, savedPosition) {
        // savedPosition 用于“返回上一页”时恢复滚动位置，若不需要可直接 return { top: 0 }
        return savedPosition ? savedPosition : { top: 0 };
    }
})

export default router